package com.iss.apartmentmanage.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ConsoleMapper {
    /**
     * 今日入住
     * @return
     */
    @Select("select count(1)from checkin_record \n" +
            "where  date_format(checkin_date, '%Y-%m-%d')=date_format(current_date(), '%Y-%m-%d') \n" +
            "group by date_format(checkin_date, '%Y-%m-%d')")
    Integer selectCheckinForDay();

    /**
     * 本月入住
     * @return
     */
    @Select("select count(1)from checkin_record \n" +
            "where  date_format(checkin_date, '%Y-%m')=date_format(current_date(), '%Y-%m') \n" +
            "group by date_format(checkin_date, '%Y-%m')")
    Integer selectCheckinForMonth();

    /**
     * 今日销售额
     * @return
     */
    @Select("select sum(money) from checkin_record \n" +
            "where  date_format(checkin_date, '%Y-%m-%d')=date_format(current_date(), '%Y-%m-%d') \n" +
            "group by date_format(checkin_date, '%Y-%m-%d')")
    Integer selectMoneyForDay();

    /**
     * 本月销售额
     * @return
     */
    @Select("select sum(money) from checkin_record \n" +
            "where  date_format(checkin_date, '%Y-%m')=date_format(current_date(), '%Y-%m') \n" +
            "group by date_format(checkin_date, '%Y-%m')")
    Integer selectMoneyForMonth();

    /**
     * 折线图count
     * @return
     */
    @Select("select date_format(checkin_date, '%Y-%m-%d') date, count(id) count\n" +
            "from checkin_record group by date_format(checkin_date,'%Y-%m-%d')")
    List<Map<String,String>> checkinChartCount();

    /**
     * 折线图money
     * @return
     */
    @Select("select date_format(checkin_date, '%Y-%m-%d') date,sum(money) money\n" +
            "from checkin_record group by date_format(checkin_date,'%Y-%m-%d')")
    List<Map<String,String>> checkinChartMoney();











}
